home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions File component in Binary mode
-
- #include "NSDLL.h"
- #include <stdio.h>
-
- unsigned char typedSample,
- Nread,
- bitCount = 8;
-
- /******************************/
- /* Read next sample from file */
- __declspec(dllexport) BOOL performFile(
- DLLData *instance, // Pointer to instance data (may be NULL)
- FILE *file, // Pointer to the opened file
- NSFloat *sample // Location to place next sample
- )
- {
-
- if (bitCount==8) {
- Nread = fread(&typedSample, sizeof(unsigned char), 1, (FILE*)file);
- bitCount=0;
- }
- if (Nread==1) {
- *sample = (NSFloat)(1 & (typedSample>>(7-bitCount++)));
- return TRUE;
- }
- else {
- fclose((FILE*)file);
- bitCount = 8;
- return FALSE;
- }
- }
-
- /********************************************/
- /* Open and the file and return its pointer */
- __declspec(dllexport) FILE *openFile(DLLData *instance, const char *filePath)
- {
- return fopen(filePath, "rb");
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- /*
- __declspec(dllexport) DLLData *allocFile(
- DLLData *oldInstance // Pointer to the last instance if reallocating
- )
- {
- DLLData *instance = NULL;
- return instance;
- }
-
- __declspec(dllexport) void freeFile(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
- */
-